{% extends 'base.html' %}

{% block title %}
  {% if currency %}编辑货币{% else %}添加货币{% endif %} - 数据管理系统
{% endblock %}

{% block breadcrumb %}
  <li class="breadcrumb-item"><a href="{{ url_for('list_currencies') }}">货币管理</a></li>
  <li class="breadcrumb-item active" aria-current="page">{% if currency %}编辑货币{% else %}添加货币{% endif %}</li>
{% endblock %}

{% block content %}
  <h2 class="page-header">{% if currency %}编辑货币{% else %}添加货币{% endif %}</h2>
  
  <form method="POST">
    <div class="row mb-3">
      <div class="col-md-6">
        <label for="code" class="form-label">货币代码 (ISO 3字母)</label>
        <input type="text" class="form-control" id="code" name="code" 
               value="{{ currency.code if currency }}" required maxlength="3">
      </div>
      <div class="col-md-6">
        <label for="symbol" class="form-label">货币符号</label>
        <input type="text" class="form-control" id="symbol" name="symbol" 
               value="{{ currency.symbol if currency }}" required>
      </div>
    </div>
    
    <div class="row mb-3">
      <div class="col-md-6">
        <label for="name_cn" class="form-label">中文名称</label>
        <input type="text" class="form-control" id="name_cn" name="name_cn" 
               value="{{ currency.name_cn if currency }}" required>
      </div>
      <div class="col-md-6">
        <label for="name_en" class="form-label">英文名称</label>
        <input type="text" class="form-control" id="name_en" name="name_en" 
               value="{{ currency.name_en if currency }}" required>
      </div>
    </div>
    
    <div class="mb-3">
      <label for="name_local" class="form-label">本地名称 (可选)</label>
      <input type="text" class="form-control" id="name_local" name="name_local" 
             value="{{ currency.name_local if currency }}">
    </div>
    
    <div class="mb-3 form-check">
      <input type="checkbox" class="form-check-input" id="is_active" name="is_active" 
             {% if currency and currency.is_active %}checked{% endif %}>
      <label class="form-check-label" for="is_active">启用该货币</label>
    </div>
    
    <button type="submit" class="btn btn-primary">{% if currency %}更新{% else %}添加{% endif %}</button>
    <a href="{{ url_for('list_currencies') }}" class="btn btn-secondary">取消</a>
  </form>
{% endblock %}